/*
 *  Copyright 2009 David Kuhn <david.s.kuhn at gmail.com>.
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *  under the License.
 */
package com.google.code.teamtools.domain.impl;

import com.google.code.teamtools.domain.IResource;
import com.google.code.teamtools.domain.IResourceOwner;

/**
 * Abstract base class of all resources.
 * 
 * @author David Kuhn
 */
public abstract class AbstractResource implements IResource
{
	private Long id = null;
    private String name;
    private IResourceOwner owner;
	
	protected AbstractResource()
	{
	}
	
	protected AbstractResource(Long id)
	{
		setId(id);
	}
	
	protected AbstractResource(String name)
    {
        this();
        setName(name);
    }
    
    protected AbstractResource(String name, IResourceOwner owner)
    {
        this(name);
        setOwner(owner);
    }
	
	/* (non-Javadoc)
	 * @see com.google.code.teamtools.domain.IEntity#getId()
	 */
	public Long getId()
	{
		return id;
	}
	
    /* (non-Javadoc)
     * @see com.google.code.teamtools.domain.IResource#getName()
     */
    public String getName()
    {
        return name;
    }

    /* (non-Javadoc)
     * @see com.google.code.teamtools.domain.IResource#getOwner()
     */
    public IResourceOwner getOwner()
    {
    	return owner;
    }
    
    /* (non-Javadoc)
     * @see com.google.code.teamtools.domain.IResource#setName(java.lang.String)
     */
    public void setName(String name)
    {
        this.name = name;
    }
    
    /* (non-Javadoc)
     * @see com.google.code.teamtools.domain.IResource#setOwner(com.google.code.teamtools.domain.IResourceOwner)
     */
    public void setOwner(IResourceOwner owner)
    {
        this.owner = owner;
    }
    
    public String toString()
    {
        StringBuilder sb = new StringBuilder();
        sb.append("AbstractResource[");
        sb.append("id:");
        sb.append(this.getId());
        sb.append("|name:");
        sb.append(this.getName());
        sb.append("|owner:");
        sb.append(this.getOwner().toString());
        sb.append("]");
        
        return sb.toString();
    }
	
	protected void setId(Long id)
	{
		this.id = id;
	}
}
